package com.digitalchina.lxnsy.xml;

import android.content.Context;

import com.digitalchina.lxnsy.toolkit.SharedPreferencesUtil;

/**
 * ================================================
 * 项目名称：bigdata
 * 类描述：
 * 包名：com.digitalchina.bigdata.xml
 * 创建人：郑皓
 * 创建时间：2016/12/23 10:42
 * 修改备注：
 * ================================================
 */
public class LocationXML {

    public static final String XML_NAME_LOCATION = "Location";
    private static final String USER_DEFAULT_VALUE = "";


    private static final String ADDRESS = "address"; //省市区
    private static final String PROVINCE = "province"; //省
    private static final String CITY = "city"; //市
    private static final String DISTRICT = "district"; //区
    private static final String STREET = "street"; //区


    /**
     * 设置定位地址
     *
     * @param ctx
     */
    public static void setLocationAddress(Context ctx, String address) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_LOCATION, ADDRESS, address);
    }

    /**
     * 获取定位地址
     *
     * @param ctx
     * @return
     */
    public static String getLocationAddress(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_LOCATION, ADDRESS, USER_DEFAULT_VALUE);
    }


    /**
     * 设置省
     *
     * @param ctx
     */
    public static void setProvince(Context ctx, String province) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_LOCATION, PROVINCE, province);
    }

    /**
     * 获取省
     *
     * @param ctx
     * @return
     */
    public static String getProvince(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_LOCATION, PROVINCE, USER_DEFAULT_VALUE);
    }


    /**
     * 设置市
     *
     * @param ctx
     * @param city
     */
    public static void setCity(Context ctx, String city) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_LOCATION, CITY, city);
    }

    /**
     * 获取市
     *
     * @param ctx
     * @return
     */
    public static String getCity(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_LOCATION, CITY, USER_DEFAULT_VALUE);
    }

    /**
     * 设置区
     *
     * @param ctx
     * @param district
     */
    public static void setDistrict(Context ctx, String district) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_LOCATION, DISTRICT, district);
    }

    /**
     * 获取区
     *
     * @param ctx
     * @return
     */
    public static String getDistrict(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_LOCATION, DISTRICT, USER_DEFAULT_VALUE);
    }

    /**
     * 设置街道
     *
     * @param ctx
     * @param street
     */
    public static void setStreet(Context ctx, String street) {
        SharedPreferencesUtil.setValue(ctx, XML_NAME_LOCATION, STREET, street);
    }

    /**
     * 获取街道
     *
     * @param ctx
     * @return
     */
    public static String getStreet(Context ctx) {
        return SharedPreferencesUtil.getValue(ctx, XML_NAME_LOCATION, STREET, USER_DEFAULT_VALUE);
    }
}
